home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / f90 / sum.z / sum
Encoding:
Text File  |  1998-10-30  |  3.7 KB  |  85 lines

  1. SUM(3I)                                                Last changed: 1-6-98
  2.  
  3.  
  4. NNAAMMEE
  5.      SSUUMM - Sums array elements
  6.  
  7. SSYYNNOOPPSSIISS
  8.      SSUUMM (([AARRRRAAYY==]_a_r_r_a_y [,,[DDIIMM==]_d_i_m] [,,[MMAASSKK==]_m_a_s_k]))
  9.  
  10.      SSUUMM (([AARRRRAAYY==]_a_r_r_a_y [,,[MMAASSKK==]_m_a_s_k]))
  11.  
  12. IIMMPPLLEEMMEENNTTAATTIIOONN
  13.      UNICOS, UNICOS/mk, and IRIX systems
  14.  
  15. SSTTAANNDDAARRDDSS
  16.      Fortran 90
  17.  
  18. DDEESSCCRRIIPPTTIIOONN
  19.      The SSUUMM intrinsic function sums all the elements of _a_r_r_a_y along
  20.      dimension _d_i_m that correspond to the true elements of _m_a_s_k.  It
  21.      accepts the following arguments:
  22.  
  23.      _a_r_r_a_y     Must be of type integer, real, or complex.  It must not be
  24.                scalar.
  25.  
  26.      _d_i_m       Must be scalar and of type integer with a value in the range
  27.                1 <= _d_i_m <= _n, where _n is the rank of _a_r_r_a_y.  The
  28.                corresponding actual argument must not be an optional dummy
  29.                argument.  This function does a check on _d_i_m when present.
  30.  
  31.      _m_a_s_k      Must be of type logical and must be conformable with _a_r_r_a_y.
  32.  
  33.      SSUUMM is a transformational intrinsic function.  The name of this
  34.      intrinsic cannot be passed as an argument.
  35.  
  36. RREETTUURRNN VVAALLUUEESS
  37.      The result is of the same type and kind type parameter as _a_r_r_a_y.  It
  38.      is scalar if _d_i_m is absent or if _a_r_r_a_y has rank one; otherwise, the
  39.      result is an array of rank _n-1 and of shape
  40.      (_d , _d , ..., _d     , _d     , ..., _d ),
  41.        1   2        _d_i_m-1   _d_i_m+1        _n
  42.      where (_d , _d , ..., _d )
  43.              1   2        _n
  44.      is the shape of _a_r_r_a_y.
  45.  
  46.      The result of SSUUMM((_a_r_r_a_y)) has a value equal to the sum of all the
  47.      elements of _a_r_r_a_y.  If _a_r_r_a_y has size 0, it has the value 0.
  48.  
  49.      The result of SSUUMM((_a_r_r_a_y,,MMAASSKK==_m_a_s_k)) has a value equal to the sum of the
  50.      elements of _a_r_r_a_y corresponding to the true elements of _m_a_s_k.  It has
  51.      the value 0 if there are no true elements.
  52.  
  53.      If _a_r_r_a_y has rank one, SSUUMM((_a_r_r_a_y,,_d_i_m[,,_m_a_s_k])) has a value equal to that
  54.      of SSUUMM((_a_r_r_a_y[,,MMAASSKK==_m_a_s_k])).  Otherwise, the value of element
  55.      (_s , _s , ..., _s     , _s     , ..., _s )
  56.        1   2        _d_i_m-1   _d_i_m+1        _n
  57.      of SSUUMM((_a_r_r_a_y,,_d_i_m[,,_m_a_s_k])) is equal to
  58.      SSUUMM((_a_r_r_a_y(_s , _s , ..., _s     , : , _s     , ..., _s )
  59.                 1   2        _d_i_m-1       _d_i_m+1        _n
  60.      [,, MMAASSKK==_m_a_s_k(_s , _s , ..., _s     , : , _s     , ..., _s )]).
  61.                    1   2        _d_i_m-1       _d_i_m+1        _n
  62.  
  63. EEXXAAMMPPLLEESS
  64.      Example 1:  The value of SSUUMM((((// 11,, 22,, 33 //)))) is 6.
  65.  
  66.      Example 2:  SSUUMM((CC,, MMAASSKK== CC ..GGTT.. 00..00)) forms the arithmetic sum of the
  67.      positive elements of CC.
  68.  
  69.      Example 3:  Assume that BB is the following array:
  70.  
  71.         | 1 3 5 |
  72.         | 2 4 6 |
  73.  
  74.  
  75.      In this case, the following are true:
  76.  
  77.      * SSUUMM((BB,, DDIIMM == 11)) is [3, 7, 11]
  78.  
  79.      * SSUUMM((BB,, DDIIMM == 22)) is [9, 12]
  80.  
  81. SSEEEE AALLSSOO
  82.      _I_n_t_r_i_n_s_i_c _P_r_o_c_e_d_u_r_e_s _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication SR-2138, for the
  83.      printed version of this man page.
  84.  
  85.